﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
	[TestClass]
	public class UserData_02_StatusChangeReport2Confirm_Test
	{
		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_Equals_NoReportType()
		{
			UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);

			{
				// completely different type - NOT equal
				object dummyObject = new object();
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(dummyObject));
			}

			{
				// different derived type
				UserData userData = new UserData_01_Priority(0x77);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData));
			}

			{
				// same object - equal
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsTrue(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// different Device value - NOT equal
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					((byte) (userData02StatusChangeReport2Confirm.Device + 1), userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// different Address value - NOT equal
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, (byte) (userData02StatusChangeReport2Confirm.Address + 10), userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// different AddressAddOn value - NOT equal
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, (byte)(userData02StatusChangeReport2Confirm.AddressAddOn + 5), userData02StatusChangeReport2Confirm.AddressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// different AddressExtension value - NOT equal
				eAddressExtension_1 addressExtension = eAddressExtension_1.Output;
				if (userData02StatusChangeReport2Confirm.AddressExtension == eAddressExtension_1.Output)
				{
					addressExtension = eAddressExtension_1.Input;
				}
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, addressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_Equals_ReportType()
		{
			ReportType_Fire reportTypeFire = new ReportType_Fire(true, eReportSubType_Fire.ExtinguishingSystem);
			UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeFire);

			{
				// same object - equal
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					userData02StatusChangeReport2Confirm.TheReportType);
				Assert.IsTrue(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// same properties but no ReportType
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					null);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// same properties but different ReportType
				ReportType_General reportTypeGeneral = new ReportType_General(false, eReportSubType_General.Revision);
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
					(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
					reportTypeGeneral);
				Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
			}

			{
				// same properties with same ReportType Sub type but different on off flag
				ReportType_Base reportTypeRet = userData02StatusChangeReport2Confirm.TheReportType;
				ReportType_Fire reportTypeRetFire = reportTypeRet as ReportType_Fire;
				if (reportTypeFire != null)
				{
					ReportType_Fire reportTypeFire2Compare = new ReportType_Fire(!reportTypeRetFire.OnOffFlag, reportTypeRetFire.ReportSubType);
				
					UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
						(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
						reportTypeFire2Compare);
					Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
				}
			}

			{
				// same properties with same ReportType Sub type but different ...
				ReportType_Base reportTypeRet = userData02StatusChangeReport2Confirm.TheReportType;
				ReportType_Fire reportTypeRetFire = reportTypeRet as ReportType_Fire;
				if (reportTypeFire != null)
				{
					eReportSubType_Fire eReportSubTypeFire = eReportSubType_Fire.General;
					if (reportTypeRetFire.ReportSubType == eReportSubType_Fire.General)
					{
						eReportSubTypeFire = eReportSubType_Fire.Automatic;
					}
					ReportType_Fire reportTypeFire2Compare = new ReportType_Fire(reportTypeRetFire.OnOffFlag, eReportSubTypeFire);

					UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm2Compare = new UserData_02_StatusChangeReport2Confirm
						(userData02StatusChangeReport2Confirm.Device, userData02StatusChangeReport2Confirm.Address, userData02StatusChangeReport2Confirm.AddressAddOn, userData02StatusChangeReport2Confirm.AddressExtension,
						reportTypeFire2Compare);
					Assert.IsFalse(userData02StatusChangeReport2Confirm.Equals(userData02StatusChangeReport2Confirm2Compare));
				}
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_GetHashCode()
		{
			{
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);
				int hashCode = userData02StatusChangeReport2Confirm.GetHashCode();
			}

			{
				ReportType_Fire reportTypeFire = new ReportType_Fire(true, eReportSubType_Fire.ExtinguishingSystem);
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeFire);
				int hashCode = userData02StatusChangeReport2Confirm.GetHashCode();
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test04_ToString()
		{
			{
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);
				string stringResult = userData02StatusChangeReport2Confirm.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				ReportType_General reportTypeGeneral = new ReportType_General(false, eReportSubType_General.Revision);
				UserData_02_StatusChangeReport2Confirm userData02StatusChangeReport2Confirm = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeGeneral);
				string stringResult = userData02StatusChangeReport2Confirm.ToString();
				Assert.IsNotNull(stringResult);
			}			
		}
	}
}
